import plugin from '../../../lib/plugins/plugin.js';
import fetch from 'node-fetch'

export class wenan extends plugin {
  constructor () {
    super({
      name: '手机反查QQ',
      dsc: '手机号查绑定QQ',
      event: 'message',
      priority: 5000,
      rule: [
        {
          reg: `^#(反查)(.*)`,
          fnc: 'fc'
        },
      ]
    })
  }
    async fc (e) {
    logger.info('[用户命令]', e.msg)
    let msg = e.msg
		let place = msg.replace(/#|反查/g, "").trim();
    let url = `https://zy.xywlapi.cc/qqphone?phone=${place}`;
    let res = await fetch(url).catch((err) => logger.error(err))
    res = await res.json()
    let num
    if(res.message === '查询成功'){
      num = `查询成功~\n神秘数字：${res.qq}\n神秘地点：${res.phonediqu}`
    } else if(res.message === '没有找到'){
      num = `暂时没有找到这个人的数据呢~`
    }
    await this.reply(`${num}`, true, { recallMsg: 30 })
  }
}